package com.aly.beanValidate.core;

import com.aly.beanValidate.core.validator.BaseType;
import org.dom4j.Element;

public class FieldDefinition {
    private final String fieldName;
    private final BaseType baseType;
    private final boolean array;

    FieldDefinition(Element element) {
        fieldName = Util.attr(element, "name");
        baseType = BaseType.getTypeByName(Util.attr(element, "type"));
        String array = Util.attr(element, "array", Boolean.FALSE.toString());
        this.array = Boolean.valueOf(array);
    }

    public FieldDefinition(String fieldName, BaseType baseType, boolean array) {
        this.fieldName = fieldName;
        this.baseType = baseType;
        this.array = array;
    }

    public BaseType getBaseType() {
        return baseType;
    }

    public boolean isArray() {
        return array;
    }

    public String getFieldName() {
        return fieldName;
    }

}
